//
// Created by fanghr on 17-12-27.
//

#ifndef PROJECT_COMMON_H
#define PROJECT_COMMON_H

#define PI 3.14159265358979323
#define MAX_PIXEL_VAL_8UC 255
//#define LOCAL_DEBUG_IMG_LOG 1

#include "../../include.h"

using namespace cv;

double GetTheta(Point2d a_tV1, Point2d a_tV2);

//求某向量长度
double GetVectorLength(Point2d a_tIn);

//求某向量数量积
double Dot(Point2d a_tV1, Point2d a_tV2);

//在图上画点
Mat MyDrawPoint(const Mat a_tSrc, Point a_tDrawP, int a_lB, int a_lG, int a_lR);

//已知两点，求方向向量
Point2d GetVector(Point2d a_tStartP, Point2d a_tEndP);

//已知方向向量，求法向量
Point2d GetLawVector(Point2d a_tVector);

//两点求距离
double GetDistance(Point2d a_tP1, Point2d a_tP2);

//阀值限制 超过上限就以上限为主 下限亦同
void TruncateByThreshold(Mat &a_tSrc, const int a_lTH_High, const int lTH_Low);

//图片直方图計算 可使用float & uchar
void HistogramCal(const Mat a_tSrc, int *a_plHistogram, int a_lSize);

//算与原点距离
double DistanceCal(double a_eP1, double a_eP2);

//直方均值化 by 设定好的上下限
void ImageEqualizeHistByBound(Mat &a_tSrc, const int a_lTH_High, const int lTH_Low);

//用直方图算标准差和平均数
void StandardDeviationCalImage(const int *a_plHistogram, const int a_lSize, double &a_eMean, double &a_eSigma);

//设定图像颜色
void SetPoint(Mat img, Point start, Vec3b a_tColor);

//灰度图转彩色图
Mat GrayToColor(const Mat a_tSrc);

//求座标是否超出范围
bool CheckBoundary(const Size a_tSize, const Point2d a_tPoint);

// 两矩阵逐元素相乘
void MatrixMulFloat(Mat a_tSrc, const Mat a_tMulMatrix);

//求Mat type
string getImgType(cv::Mat frame);

double FindVectorMultipleOfMeetPoint(Point2d a_tSrc1, Point2d a_tV1, Point2d a_tSrc2, Point2d a_tV2);

//求兩线段的交点
Point2d FindMeetPoint(Point2d a_tSrc1, Point2d a_tV1, Point2d a_tSrc2, Point2d a_tV2);

#endif //PROJECT_COMMON_H
